package com.yitiao.snowflake;

/**
 * 测试类
 * 一条coding
 */
public class TestSnowFlake {
	//测试1秒能够生成的id个数
	public static void generateIdsInOneSecond() {
		 SnowFlake idWorker = new SnowFlake(1, 1);
		 long start = System.currentTimeMillis();
		 int i = 0;
		 for (; System.currentTimeMillis() - start <2; i++) {
			 System.out.println(idWorker.nextId());
		 }
		 long end = System.currentTimeMillis();
		 System.out.println("耗时："+ (end - start));
		 System.out.println("生成id个数："+ i);
	}

	public static void main(String[] args) {
		/*
		  测试出同一毫秒内的id为递增的
		  1640273390411583494
		  1640273390411583495
		  下一毫秒
		  1640273390415777792
		  1640273390415777793
		  1640273390415777794
		 */
		 generateIdsInOneSecond();
		SnowFlake idWorker = new SnowFlake(1, 1);
		System.out.println(idWorker.nextId());
	}
}